package com.woniu.cms.client.core.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

@Configuration
@EnableKnife4j
@EnableSwagger2WebMvc //兼容版本问题
public class Swagger2Config {

    @Bean
    public Docket create(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class)) // 扫描注解
//                .apis(RequestHandlerSelectors
//                        .basePackage("com.wn.pms.product.core.controller"))   //扫描指定的包
                .build();
    }

    public ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .version("1.0")
                .title("客户管理服务接口")
                .build();
    }
}